(function (owner) {

    owner.WEIXIN_OAUTH_H5_URL = 'http://yhaoquan.imwork.net';

    /**
     * 获取URL中的参数
     * @param name
     * @returns {*}
     */
    owner.getRequestParam = function(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
        var r = window.location.search.substr(1).match(reg); //匹配目标参数
        if(r != null) return decodeURI(r[2]);
        return null; //返回参数值
    };


    /**
     * 获取表单数据
     * @param formId 表单ID
     * @param flag 是否包含空表单true是，false否
     * @returns {{}}
     */
    owner.getFormData = function(formId, flag) {
        var o = {};
        $.each($(formId).serializeArray(), function(index) {
            if(undefined == flag || flag == false) {
                if (this['value'] != undefined && this['value'].length > 0) {
                    if (o[this['name']]) {
                        o[this['name']] = o[this['name']] + "," + this['value'];
                    } else {
                        o[this['name']] = this['value'];
                    }
                }
            } else {
                if (o[this['name']]) {
                    o[this['name']] = o[this['name']] + "," + this['value'];
                } else {
                    o[this['name']] = this['value'];
                }
            }
        });
        return o;
    };

})(window.Commons = {});